<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script>
			function pageVisibilityChange() {
				var that = this,
					hiddenProperty = 'hidden' in document ? 'hidden' : 'webkitHidden' in document ? 'webkitHidden' : 'mozHidden' in document ? 'mozHidden' : null,
					visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange'),
					onVisibilityChange = function() {
						if (!document[hiddenProperty]) {
							console.log('页面激活');
						} else {
							console.log('页面非激活');
						}
					};
				document.addEventListener(visibilityChangeEvent, onVisibilityChange);
			}
			pageVisibilityChange();
		</script>
	</body>
</html>
